﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServerFrame;
using Protocol;
using Protocol.DTO;
using Servertest.Tools;

namespace Servertest.Logic.Login
{
    class LoginHandler:AbsOnceHandler,IMessageHendler
    {
        public LoginHandler() {
            Logic_Type = GameProtocol.Login;            //
        }

        public void OnClientClose(MyToken token, string error){
            
        }

        public void OnClientConnected(MyToken token){
            
        }

        public void OnMessageReceive(MyToken token, TransModel model){
            switch (model.command)
            {
                case LoginProtocol.Login_CREQ:
                    //登陆请求
                    UserDTO dto = model.GetMessage<UserDTO>();
                    if (dto == null) {
                        return;
                    }

                    //
                    EventExcuteUtil.Instance.Excute(
                        () =>
                        {

                        }
                        );

                    //todo从缓冲区读取用户信息，判断是否可以登录
                    break;

                   
                case LoginProtocol.Reg_CREQ:    //注册请求
                    break;


                default:
                    break;
            }
        }
    }
}
